﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
using System.Configuration;

namespace Bussiness
{
    class SMTP
    {
        internal static bool EnviarMail(string de, string para, string asunto, string mensaje)
        {
            bool result = false;

            try
            {
                MailMessage message = new MailMessage();
                message.From = new MailAddress(de);
                message.To.Add(para);
                message.Subject = asunto;
                message.Body = mensaje;
                message.IsBodyHtml = true;
                //SmtpClient smtp = new SmtpClient("yoursmtphost");
                var smtp = new SmtpClient(ConfigurationManager.AppSettings["MailConfigSMTPServer"], int.Parse(ConfigurationManager.AppSettings["MailConfigSMTPPort"]))
                {
                    Credentials = new NetworkCredential(ConfigurationManager.AppSettings["MailConfigSMTPUser"], ConfigurationManager.AppSettings["MailConfigSMTPPassword"]),
                    EnableSsl = true
                };
                smtp.Send(message);
                result = true;
            }
            catch (Exception ex)
            { 
                
            }
            return result;
        }
    }
}
